import { BaseModel, sequelize, Sequelize } from "./basemodel.js";

class ApiKeys extends BaseModel {
	static init() {
		return super.init(
			{
				key_id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
				employer_id: { type: Sequelize.INTEGER, allowNull: false },
				api_key: { type: Sequelize.STRING, allowNull: false, unique: true },
				api_secret: { type: Sequelize.STRING, allowNull: false },
				name: { type: Sequelize.STRING, allowNull: false },
				description: { type: Sequelize.TEXT },
				permissions: { type: Sequelize.TEXT },
				status: { 
					type: Sequelize.ENUM('active', 'inactive', 'revoked'),
					defaultValue: 'active'
				},
				expires_at: { type: Sequelize.DATE },
				last_used_at: { type: Sequelize.DATE },
				created_at: { type: Sequelize.DATE, allowNull: false },
				updated_at: { type: Sequelize.DATE, allowNull: false }
			},
			{
				sequelize,
				tableName: "api_keys",
				modelName: "api_keys",
				timestamps: true,
				createdAt: 'created_at',
				updatedAt: 'updated_at'
			}
		);
	}
}

ApiKeys.init();

export default ApiKeys; 